package com.docchatlink.constant;

import lombok.Getter;

/**
 * 电话质检的请求回复的枚举类型
 *
 * @Author: brucezhang
 * @Date: 2023/11/02/15:51
 * @Description:
 */

@Getter
public enum MethodEnum {
    ERROR(0, "错误"),
    ERROR9999(9999, "错误"),
    CALL(1, "请求"),
    CALLED(2, "回复"),
    RESP_ALL(666, "全部回复"),
    RESOURCE(99, "来源"),
    ;

    MethodEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    private Integer code;
    private String value;

    /**
     * 查找枚举
     */
    public static MethodEnum findByCode(Integer code) {
        for (MethodEnum batchTypeEnum : MethodEnum.values()) {
            if (batchTypeEnum.code.equals(code)) {
                return batchTypeEnum;
            }
        }
        return null;
    }

    /**
     * 查找枚举
     */
    public static MethodEnum findByValue(String value) {
        for (MethodEnum batchTypeEnum : MethodEnum.values()) {
            if (batchTypeEnum.value.equals(value)) {
                return batchTypeEnum;
            }
        }
        return null;
    }
}
